<template>
  <div class="cart-content-box" >
    <img class="ok" :src="choose ? srcs : nosrc"  alt=""  @click="handlechoose(item)" />
    <img class="mingoods" :src="item.goodsimg" alt="" />
    <div class="mingoods-delia">
      <div class="mingoods-delia-name">{{item.goodsname}}</div>
      <div class="mingoods-delia-priace">{{item.price}}</div>
      <div class="jj">
        <img @click="handleJJ(item)"  class="jian" src="../../../static/images/jian.png" alt="" />
        <p class="num">{{item.cishu}}</p>
        <img @click="handleJ(item)" class="jia" src="../../../static/images/jia.png" alt="" />
      </div>
    </div>
  </div>

</template>

<script>
  import Self from '@/self'
  export default{
    props: [
      'item',
    ],
    data() {
      return {
            num:0,
            goods:{},
            onegoods:{},
            srcs: require('../../../static/images/ok.png'),
            nosrc: require('../../../static/images/timg.jpg'),
            choose:true

      }
    },
    onLoad(){
      if(this.item.choose===false ){
        this.choose=false;
      }
    },
    onShow(){
      if(this.item.choose===false ){
        this.choose=false;
      }
    },


    methods:{
      handlechoose(a){
        a.choose=!a.choose;
        this.choose=a.choose;
        Self.$emit('choose',a)
        // console.log(a.choose);
        // let b= a;
        // b.choose=false;

      },
      handleJ(ia){
        // console.log(ia);
        // this.onegoods=ia;
         ia.cishu++;
        let a=ia.cishu;
        this.goods.cishu =a;
        this.goods.goodsname=ia.goodsname;
        this.goods.price=ia.price;
        this.goods.goodsid=ia.goodsid;
        this.goods.goodsimg=ia.goodsimg;
        this.goods.choose=ia.choose;
        // console.log(ia);
        Self.$emit('addonegoods',this.goods);
        // console.log(wx.getStorageSync('goodsid'));
        // console.log(this.ia.GoodsId)

      },
      handleJJ(ia){

        // console.log(ia);

        let that=this;
        wx.showModal({
          title: '大哥',
          content: '小弟我这就给您跪下了 别点确定阿',
          success (res) {
            if (res.confirm) {
              ia.cishu--;
              let  b=ia;
              Self.$emit('remove',b);
              Self.$emit('removed',b);
            } else if (res.cancel) {
            }
          }
        })

      }
      },
    mounted(){
      Self.$on("allchooseTrue", function (a) {
           this.choose=true;
      }.bind(this));
      Self.$on("allchooseFalse", function (a) {
        this.choose=false;
      }.bind(this));
    },



  }

</script>
<style scoped>
  .ok{
    height: 50rpx;
    width: 50rpx;
    border-radius: 50%;
    border:1rpx solid #ccc;
  }
  .laj{
    height: 70%;
    width:14%;

  }
  .cart-content-box{
    height: 125rpx;
    width:100%;
    display: flex;
    align-items: center;
  }
  .mingoods{
    height: 70%;
    width:100rpx;
  }
  .mingoods-delia{
    height: 70%;
    width:80%;
    font-size: 26rpx;
    position: relative;
  }
  .mingoods-delia-name{
    height: 50%;
  }
  .mingoods-delia-priace{
    height: 50%;
    color:red;
  }
  .jj{
    display: flex;

  }
  .jia{
    height:50rpx;
    width:50rpx;
    position:absolute;
    right: 41rpx;
    bottom:0rpx;

  }
  .jian{
    height:50rpx;
    width:50rpx;
    position:absolute;
    bottom:0rpx;
    right: 131rpx;

  }
  .num{
    height:50rpx;
    width:50rpx;
    position:absolute;
    bottom:0rpx;
    right: 67rpx;
    line-height:50rpx;


  }

</style>
